import sys

from PySide6.QtGui import QAction
from PySide6.QtWidgets import QApplication, QMainWindow
from renix_py_api.renix import initialize

from exer_lib.ui import Ui_MainWindow


class MainWindow(QMainWindow):
    def __init__(self):
        super(MainWindow, self).__init__()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)
        self.ui.action_Open.triggered.connect(self.fileOpen)
        self.ui.spinBox.valueChanged.connect(self.on_spin_box_value_changed)
        # 测试renix api
        self.cl_instance = initialize(multi_thread_support=True, log=True)

    def on_spin_box_value_changed(self, v):
        pass

    def fileOpen(self):
        print(f"fileOpen entry")

    def onActionTrigger(self, action:QAction):
        print(f"onActionTriggered entry, {type(action)}, text:{action.text()}, objectName:{action.objectName()}")
        if action == self.ui.action_Close:
            self.fileClose()

    def fileClose(self):
        print(f"fileClose entry")

if __name__ == "__main__":
    app = QApplication(sys.argv)

    window = MainWindow()
    window.setWindowTitle("RGB Spin slider")
    window.show()

    sys.exit(app.exec())